<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('生产实习过程管理')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>
							编号：<input type="text" name="productionId"/>
						</li>
						<li>
							学生学号：<input type="text" name="studentId"/>
						</li>
						<li>
							类别：<input type="text" name="worklyCategory"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">

		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('system:teaaudit:edit')}]];
	var prefix = ctx + "sau/teaaudit";

	$(function() {
		var options = {
			url: prefix + "/selectWeeks",
			updateUrl: prefix + "/edit/{id}",
			sortName: "worklyId",
			modalName: "周报",
			columns: [
				{
					field: 'worklyId',
					title: '周报编号',
					visible: false
				},
				{
					field: 'productionId',
					title: '编号'
				},
				{
					field: 'worklyCategory',
					title: '类别'
				},
				{
					field: 'worklyOver',
					title: '截至时间'
				},
				{
					field: 'studentId',
					title: '学生学号'
				},
				{
					field: 'studentName',
					title: '学生姓名'
				},
				{
					field: 'worklyMain',
					cellStyle: formatTableUnit,
					formatter: paramsMatter,
					title: '周报内容'
				},
				{
					field: 'worklyScore',
					title: '分数'
				},
				{
					field: 'worklyActScore',
					title: '实际得分'
				},
				{
					field: 'worklyRemark',
					cellStyle: formatTableUnit,
					formatter: paramsMatter,
					title: '教师评语'
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.worklyId+ '\')"><i class="fa fa-edit"></i>批阅</a> ');
						return actions.join('');
					}
				}]
		};
		$.table.init(options);
	});

	function edit(id) {
		table.set();
		if($.common.isEmpty(id) && table.options.type == table_type.bootstrapTreeTable) {
			var row = $("#" + table.options.id).bootstrapTreeTable('getSelections')[0];
			if ($.common.isEmpty(row)) {
				$.modal.alertWarning("请至少选择一条记录");
				return;
			}
			var url = table.options.updateUrl.replace("{id}", row[table.options.uniqueId]);
			$.modal.open("批阅" + table.options.modalName, url);
		} else {
			$.modal.open("批阅" + table.options.modalName, $.operate.editUrl(id));
		}
	}

	function paramsMatter(value, row, index) {
		var span = document.createElement("span");
		span.setAttribute("title", (typeof(value) == "undefined") ? "-" : value);
		span.innerHTML = (typeof(value) == "undefined") ? "-" : value;
		return span.outerHTML;
	}
	//td宽度以及内容超过宽度隐藏
	function formatTableUnit(value, row, index) {
		return {
			css: {
				"white-space": "nowrap",
				"text-overflow": "ellipsis",
				"overflow": "hidden",
				"max-width": "60px"
			}
		}
	}

</script>
</body>
</html>